<template>
	<scroll-view scroll-y style="max-height:calc(100vh - 88rpx);width: 100%;" @scrolltolower="getList">
		<view class="pt10"></view>

		<u-cell-item :key="index" v-for="(item,index) in list" :titleStyle="{fontSize:'30rpx',color:'#222'}"
			:title="item.title" :label="item.created_at | date" :labelStyle="{fontSize:'24rpx',color:'#888'}"
			:value="item.amount" :valueStyle="{fontSize:'32rpx',color:'#222'}" bg-color="#fff" :arrow="false">
		</u-cell-item>

		<view class="pt15 pb15">
			<u-empty text="亲，暂无相关数据" v-if="list.length==0 && status=='nomore'" icon-size="200" font-size="28"
				margin-top="200"></u-empty>

			<u-loadmore v-else :status="status" />
		</view>
	</scroll-view>
</template>

<script>
	import * as Api from '@/api/assets/income/index.js'
	export default {
		data() {
			return {
				refreshing: false,
				status: 'loadmore',
				page: 0,
				list: [],
			}
		},
		methods: {
			// onRefresh() {
			// 	if (this.status == 'loading') return;
			// 	this.status = 'loadmore'
			// 	this.refreshing = true;
			// 	this.page = 0;
			// 	this.getList();
			// },
			async getList() {
				if (this.status == 'loading' || this.status == 'nomore') return;
				this.status = 'loading';

				const res = await Api.weekPrizeList(++this.page);
				if (res.data) {
					const {
						current_page,
						total,
						data
					} = res.data;
					this.page = current_page;

					this.list = this.list.concat(data)

					setTimeout(() => {
						this.refreshing = false;
						if (this.list.length >= total) this.status = 'nomore';
						else this.status = 'loadmore';
					}, 500)
				}
				// console.log(res);
			}
		},
		mounted() {

		},
		created() {
			this.getList();
		},
	}
</script>